#pragma once

#include "cTexture.h"
#include "Globals.h"
#include "Collider.h"
#include "Tile.h"

#define FRAME_DELAY		3
#define STEP_LENGTH		2
#define JUMP_HEIGHT		116
#define JUMP_STEP		4

class cRect
{
public:
	int left,top,
		right,bottom;
};

class cBicho
{
public:
	enum State{
		STATE_LOOKLEFT,
		STATE_LOOKRIGHT,
		STATE_WALKLEFT,
		STATE_WALKRIGHT,
		STATE_JUMPINGRIGHT,
		STATE_JUMPINGLEFT,
		STATE_FLYING,
		STATE_EXPLODING,
		STATE_READYFORDELETION,
		STATE_HURT
	};

	enum Type{
		PLAYER,
		PROJECTILE,
		ENEMY
	};

	cBicho(void);
	cBicho(int x,int y,int w,int h, Type);
	~cBicho(void);

	void SetPosition(int x,int y);
	void GetPosition(int *x,int *y);
	void SetTile(int tx,int ty);
	void GetTile(int *tx,int *ty);
	Type GetType();
	void SetType(Type);
	void SetWidthHeight(int w,int h);
	void GetWidthHeight(int *w,int *h);
	Collider * GetCollider();

	bool Collides(cRect *rc);
	bool CollidesMapWall(Tile *map, bool right);
	bool CollidesMapFloor(Tile *map);
	void GetArea(cRect *rc);
	void DrawRect(int tex_id, float xo, float yo, float xf, float yf);
	void DrawRect(int, float, float, float, float, int, int);
	void DrawRect(int, float, float, float, float, int, int, float);
	bool IsColliding(Tile *);

	void MoveRight(Tile *map);
	void MoveLeft(Tile *map);
	void Jump(Tile *map);
	void Stop();
	cBicho * Shoot(float, float);
	virtual void Logic(Tile *map);

	virtual void LoadAnimations();
	virtual void Draw(int);

	State GetState();
	void SetState(State);

	int NextFrame(int max);
	int  GetFrame();

	int GetLife();
	void SetLife(int);
	

private:
	State m_state;
	Type m_type;

	bool jumping;
	int jump_alfa;
	int jump_y;
	int m_life;

	int seq,delay;
	Collider * mp_collider;
	int m_inmunityCountdown;
	State m_statePreviousToInmunity;
	const int RAD2DEG = 57.2957795;
};
